package com.xzm.project.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

/**
 * author : xuzongmeng
 * date   : 2019/9/2
 * desc   : 描述 https://blog.csdn.net/harvic880925/article/details/24516545
 */
public class DatabaseHelper extends SQLiteOpenHelper {
    private static final String DB_NAME = "mydata.db"; //数据库名称
    public DatabaseHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        long pageSize = db.getPageSize();
        String sql = "create table user(username varchar(20) not null , password varchar(60) not null );";
//        db.insert()
//        db.delete()
//        db.update()
//        db.query()
        db.execSQL(sql);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
